home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9969 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  58 lines

  1. Path: academy.bastad.se!news
  2. From: mikael@academey.bastad.se (Mikael Bergqvist)
  3. Newsgroups: comp.lang.c++
  4. Subject: Template declaration in h file and cpp file
  5. Date: Tue, 05 Mar 1996 11:53:59 GMT
  6. Organization: Connection Bastad
  7. Message-ID: <4hhafd$f8d@academy.bastad.se>
  8. NNTP-Posting-Host: academy.bastad.se
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. X-Newsreader: Forte Free Agent 1.0.82
  13.  
  14. Hi!
  15.  
  16. I┤m having a problem with the following code:
  17.  
  18. SORT.H:
  19.  
  20. template <class TArray>
  21. void QSort(int lo,int hi,TArray *array);
  22.  
  23. END SORT.H
  24.  
  25. SORT.CPP
  26. #include "sort.h"
  27. template <class TArray>
  28. void QSort(int lo,int hi,TArray *array)
  29. {
  30.  
  31. ..... some code
  32. }
  33.  
  34. END SORT.CPP
  35.  
  36. TEST.CPP
  37.  
  38. #include "sort.h"
  39.  
  40. int main(void)
  41. {
  42.     int array[10]={.........};
  43.     QSort(0,9,array);
  44. }
  45.  
  46. END TEST.CPP
  47.  
  48. The problem is that the linker returns the following error:
  49. Undefinded symbol QSort(int,int,int far *); in module test.cpp
  50.  
  51. This problem doesent occur if the main function is in SORT.CPP below
  52. the QSort function. 
  53.  
  54. HELP!
  55.  
  56. /Mikael
  57.  
  58.